import request from '@/utils/request';
import { AxiosPromise } from 'axios';
import { SheetFieldVO, SheetFieldForm, SheetFieldQuery } from '@/api/sheet/sheetField/types';

/**
 * 查询应用字段列表
 * @param query
 * @returns {*}
 */

export const listSheetField = (query?: SheetFieldQuery): AxiosPromise<SheetFieldVO[]> => {
  return request({
    url: '/system/sheetField/list',
    method: 'get',
    params: query
  });
};

/**
 * 查询应用字段详细
 * @param sheetFiledId
 */
export const getSheetField = (sheetFiledId: string | number): AxiosPromise<SheetFieldVO> => {
  return request({
    url: '/system/sheetField/' + sheetFiledId,
    method: 'get'
  });
};

/**
 * 新增应用字段
 * @param data
 */
export const addSheetField = (data: SheetFieldForm) => {
  return request({
    url: '/system/sheetField',
    method: 'post',
    data: data
  });
};

/**
 * 修改应用字段
 * @param data
 */
export const updateSheetField = (data: SheetFieldForm) => {
  return request({
    url: '/system/sheetField',
    method: 'put',
    data: data
  });
};

/**
 * 删除应用字段
 * @param sheetFiledId
 */
export const delSheetField = (sheetFiledId: string | number | Array<string | number>) => {
  return request({
    url: '/system/sheetField/' + sheetFiledId,
    method: 'delete'
  });
};

/**
 * 修改应用字段
 * @param data
 */
export const updateBatchSheetField = (data: SheetFieldVO[]) => {
  return request({
    url: '/system/sheetField/updateBatchSheetField',
    method: 'post',
    data: data
  });
};

/**
 * 获取所有应用字段
 * @param query
 */
export const listSheetFieldAll = (query?: SheetFieldQuery): AxiosPromise<SheetFieldVO[]> => {
  return request({
    url: '/system/sheetField/listAll',
    method: 'get',
    params: query
  });
};
